<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改mater')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-mater-edit" th:object="${wxMater}">
            <input name="materId" th:field="*{materId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">材料员姓名：</label>
                <div class="col-sm-8">
                    <input name="materName" th:field="*{materName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">材料员手机号：</label>
                <div class="col-sm-8">
                    <input name="materPhone" th:field="*{materPhone}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/mater";
        $("#form-mater-edit").validate({
            onkeyup: false,
            rules:{
                materPhone:{
                    isPhone:true,
                    remote: {
                        url: prefix + "/checkPhoneUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "materId": function() {
                                return $("#materId").val();
                            },
                            "materPhone": function () {
                                return $.common.trim($("#materPhone").val());
                            }
                        },
                        dataFilter: function (data, type) {
                            return $.validate.unique(data);
                        }
                    }
                },
            },
            messages: {
                "materPhone":{
                    remote: "手机号码已经存在"
                }
            },
            // 如果为true，当表单得到焦点时，移除在该表单上的errorClass并隐藏所有错误消息
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-mater-edit').serialize());
            }
        }
    </script>
</body>
</html>